home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0021_Delphi DDE Linking.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-22  |  1.9 KB  |  78 lines

  1.  
  2.      unit Netscp1;
  3.      
  4.      interface
  5.      
  6.      uses
  7.        SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  8.        Forms, Dialogs, StdCtrls, DdeMan;
  9.      
  10.      type
  11.        TForm1 = class(TForm)
  12.          DdeClientConv1: TDdeClientConv;
  13.          Button1: TButton;
  14.          Button2: TButton;
  15.          Button3: TButton;
  16.          LinkStatus: TEdit;
  17.          Label1: TLabel;
  18.          Label2: TLabel;
  19.          URLName: TEdit;
  20.          procedure Button1Click(Sender: TObject);
  21.          procedure FormCreate(Sender: TObject);
  22.          procedure Button2Click(Sender: TObject);
  23.          procedure Button3Click(Sender: TObject);
  24.        private
  25.          { Private declarations }
  26.        public
  27.          { Public declarations }
  28.        end;
  29.      
  30.      var
  31.        Form1: TForm1;
  32.        LinkOpened: Integer;
  33.      
  34.      implementation
  35.      
  36.      {$R *.DFM}
  37.      
  38.      procedure TForm1.Button1Click(Sender: TObject);
  39.      begin
  40.        If LinkOpened = 0 Then
  41.        Begin
  42.          DdeClientConv1.SetLink('Netscape', 'WWW_OpenURL');
  43.          If DdeClientConv1.OpenLink Then
  44.          begin
  45.            LinkStatus.Text := 'Netscape Link has been opened';
  46.            LinkOpened := 1;
  47.          end
  48.          else
  49.            LinkStatus.Text := 'Unable to make Netscape Link';
  50.        End;
  51.      end;
  52.      
  53.      procedure TForm1.FormCreate(Sender: TObject);
  54.      begin
  55.        LinkOpened := 0;
  56.      
  57.      end;
  58.  
  59.      procedure TForm1.Button2Click(Sender: TObject);
  60.      begin
  61.        DdeClientConv1.CloseLink;
  62.        LinkOpened := 0;
  63.        LinkStatus.Text := 'Netscape Link has been closed';
  64.      end;
  65.      
  66.      procedure TForm1.Button3Click(Sender: TObject);
  67.      var
  68.         ItemList: String;
  69.      begin
  70.        If LinkOpened <> 0 Then
  71.        begin
  72.          ItemList := URLName.Text + ',,0xFFFFFFFF,0x3,,,';
  73.          DdeClientConv1.RequestData(ItemList);
  74.        End;
  75.      end;
  76.      
  77.      end.
  78.